package com.cuotibao.zhuoxiao.basics.utils;

import android.app.Activity;
import android.content.Intent;
import android.text.TextUtils;
import android.webkit.JavascriptInterface;

import com.cuotibao.zhuoxiao.basics.GlobalConstant;

/**
 * @author hdx on 2019/5/7.
 */
public class ShowImageJsWebInterface {
    private Activity mActivity;

    public ShowImageJsWebInterface(Activity activity) {
        this.mActivity = activity;
    }

    @JavascriptInterface
    public void showImage(final String currentImage, final String[] images) {
        if (TextUtils.isEmpty(currentImage)||images==null||images.length==0)return;
        mActivity.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                Intent i = new Intent();
                i.setAction("com.tenglong.teacher.PhotoBrowserActivity");
                i.putExtra(GlobalConstant.KEY_IMAGE_URLS, images);
                i.putExtra(GlobalConstant.KEY_CURRENT_IMAGE_URL, currentImage);
                mActivity.startActivity(i);
                mActivity.overridePendingTransition(0, 0);
            }
        });
    }
}
